package cn.bonoon.controllers.fmm;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.bonoon.core.plugins.AccountService;
import cn.bonoon.entities.AccountEntity;
import cn.bonoon.kernel.annotations.QueryExpression;
import cn.bonoon.kernel.web.ButtonEventType;
import cn.bonoon.kernel.web.annotations.grid.GridStandardDefinition;
import cn.bonoon.kernel.web.controllers.AbstractGridController;

@Controller
@RequestMapping("s/sys/admin")
public class AdminController extends AbstractGridController<AccountEntity, AdminItem> {

	private final AccountService service;

	@Autowired
	public AdminController(AccountService service) {
		super(service);
		this.service = service;
	}

	@Override
	@QueryExpression("x.flag={FIELD cn.bonoon.kernel.FlagType ADMIN}")
	@GridStandardDefinition(deleteOperation = false, autoOperation = false)
	protected AccountService initLayoutGrid(LayoutGridRegister register) throws Exception {
		// register.add("x.flag=?", FlagType.ADMIN);
		register.button("权限管理", "adminPrivilege.do", ButtonEventType.DIALOG);
		return service;
	}

	@Override
	protected Class<AdminItem> itemClass() {
		return AdminItem.class;
	}
}
